using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.CompilerServices;
using OpenComposite.HumanActivity.Contracts.Participants;

namespace OpenComposite.EII.Forms
{
	/// <summary>
	/// Summary description for FormInput.
	/// </summary>
	internal class FormInput : System.Windows.Forms.Form
	{

		#region Members

		#region Private Vars

		/// <summary>
		/// The new created string.
		/// </summary>
		private IParticipant m_Participant;

		#endregion Private Vars

		#region Private Methods

		#endregion Private Methods

		#region Eventhandlers

		/// <summary>
		/// OK Button.
		/// </summary>
		private void btnOk_Click(object sender, System.EventArgs e)
		{
			EmailParticipant email = m_Participant as EmailParticipant;
			PropertyParticipant prop = m_Participant as PropertyParticipant;
			if ( email != null ) {
				email.EmailAddress = txtInput.Text;
			} else if ( prop != null ) {
				prop.Property = txtInput.Text;
			}
			this.Close();
		}


		/// <summary>
		/// Cancel Button.
		/// </summary>
		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			m_Participant = null;
			this.Close();
		}


		/// <summary>
		/// Form Load.
		/// </summary>
		private void FormInput_Load(object sender, System.EventArgs e)
		{
			this.Show();
			txtInput.Focus();
		}


		#endregion Eventhandlers

		#endregion Members

		#region Interface

		#region Properties

		/// <summary>
		/// Get the participant.
		/// </summary>
		public IParticipant Participant
		{
			get { return m_Participant; }
			set { m_Participant = value; }
		}


		#endregion Properties

		#region Methods

		#endregion Methods

		#endregion Interface

		#region Contstructors

		/// <summary>
		/// Create a new form object.
		/// </summary>
		internal FormInput(IParticipant part)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			this.Text = part.Display;
			if ( part is EmailParticipant ) {
				lblInput.Text = "Email Address:";
			} else if ( part is PropertyParticipant ) {
				lblInput.Text = "Property Name:";
			} else {
				lblInput.Text = "Value:";
			}
			m_Participant = part;
		}


		#endregion Constructors

		#region Systemstuff

		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Button btnOk;
		private System.Windows.Forms.Label lblInput;
		private System.Windows.Forms.TextBox txtInput;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			if ( disposing ) {
				if ( components != null ) {
					components.Dispose();
				}
			}
			base.Dispose(disposing);
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.btnCancel = new System.Windows.Forms.Button();
			this.btnOk = new System.Windows.Forms.Button();
			this.txtInput = new System.Windows.Forms.TextBox();
			this.lblInput = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// btnCancel
			// 
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(199, 86);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(85, 25);
			this.btnCancel.TabIndex = 2;
			this.btnCancel.Text = "&Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// btnOk
			// 
			this.btnOk.Location = new System.Drawing.Point(92, 86);
			this.btnOk.Name = "btnOk";
			this.btnOk.Size = new System.Drawing.Size(85, 25);
			this.btnOk.TabIndex = 1;
			this.btnOk.Text = "&OK";
			this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
			// 
			// txtInput
			// 
			this.txtInput.Location = new System.Drawing.Point(12, 41);
			this.txtInput.Name = "txtInput";
			this.txtInput.Size = new System.Drawing.Size(352, 20);
			this.txtInput.TabIndex = 0;
			// 
			// lblInput
			// 
			this.lblInput.AutoSize = true;
			this.lblInput.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.lblInput.Location = new System.Drawing.Point(12, 25);
			this.lblInput.Name = "lblInput";
			this.lblInput.Size = new System.Drawing.Size(37, 13);
			this.lblInput.TabIndex = 46;
			this.lblInput.Text = "Value:";
			// 
			// FormInput
			// 
			this.AcceptButton = this.btnOk;
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(376, 123);
			this.Controls.Add(this.txtInput);
			this.Controls.Add(this.lblInput);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOk);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "FormInput";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Enter Value";
			this.Load += new System.EventHandler(this.FormInput_Load);
			this.ResumeLayout(false);
			this.PerformLayout();

		}
		#endregion

		#endregion Systemstuff
	}
}
